package com.jar.exercise.算法.最大相同子串;

/**
 * @author ZhangShengHao
 * @className Demo
 * @description TODO
 * @date 2020/3/4 21:09
 */
public class Demo {

	public static void main(String[] args) {
		System.out.println(text("asdafghjka", "aaasdfg"));

	}


	public static String text(String s1, String s2) {
		String max = "";
		String min = "";
		max = (s1.length() > s2.length()) ? s1 : s2;
		min = (max == s1) ? s2 : s1;


		for (int x = 0; x < min.length(); x++) {
			for (int y = 0, z = min.length() - x; z != min.length() + 1; y++, z++) {
				String temp = min.substring(y, z);

				if (max.contains(temp)) {
					return temp;
				}
			}
		}
		return null;

	}

}
